Imports Microsoft.VisualBasic
Imports Cdm.DataCore
Imports Cdm.DataCore.Entities
Imports Cdm.DataCore.UserSecurity
Imports System.Data
Imports System.Data.SqlClient

Public Class BatchUploadPortletDisplay

    Public Shared Function DisplayActivityList(ByVal sortField As String, ByVal isAscending As Boolean) As System.Data.DataTable
        Dim strConnectionString As String = EntityController.AppConnectString
        Dim connection As SqlConnection = _
                    New SqlConnection(strConnectionString)
        Dim ds As DataSet = New DataSet()
        Dim sortBy As String = String.Concat("ORDER BY ", sortField)
        If isAscending Then
            sortBy = String.Concat(sortBy, " DESC")
        End If

        Try
            connection.Open()
            Dim conn As SqlConnection = New SqlConnection(strConnectionString)
            Dim da As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM ExpenditureBatchUploadActivity " & sortBy, connection)
            da.Fill(ds)

        Catch e As SqlException
            Throw e
        Finally
            connection.Close()
        End Try

        Return ds.Tables(0)

    End Function
End Class
